/* Original Author:  Dominick O'Dierno
 * Date: 2007   odiernod@gmail.com     --Originally intended for use with DOMercury:  http://www.odierno.com/domercury
 * Description: Provides actions for an Start Menu Item
 * 
 * --CHANGELOG--
 * 
 * */
using System;
using System.Collections.Generic;
using System.Text;
using DOMercury.Interfaces;

namespace DOMercury.Actions
{
    class StartMenuLaunchAction : IAction
    {
        #region IAction Members

        public string ActionType
        {
            get { return "Launch"; }
        }

        public string Description
        {
            get { return "Launch the Start Menu Item"; }
        }

        public string ParamDescription
        {
            get { return "Unused"; }
        }

        public string ParameterType
        {
            get { return "Command Line"; }
        }

        public bool Perform(IItem item, object specialParams)
        {
            try
            {
                System.Diagnostics.Process.Start(item.DisplayDesc);
                return true;
            }
            catch
            {
                return false;
            }
        }

        #endregion
    }

    class StartMenuOpenFolderAction : IAction
    {
        #region IAction Members

        public string ActionType
        {
            get { return "Explore Parent Folder"; }
        }

        public string Description
        {
            get { return "Opens the Folder Containing the Item"; }
        }

        public string ParamDescription
        {
            get { return "Unused"; }
        }

        public string ParameterType
        {
            get { return "Command Line"; }
        }

        public bool Perform(IItem item, object specialParams)
        {
            try
            {
                System.Diagnostics.Process.Start(System.IO.Path.GetDirectoryName(item.DisplayDesc));
                return true;
            }
            catch
            {
                return false;
            }
        }

        #endregion
    }

    //Re enable this when regular expression of target area works
    //class StartMenuOpenInstallFolderAction : IAction
    //{
    //    #region IAction Members

    //    public string ActionType
    //    {
    //        get { return "Explore Parent Folder"; }
    //    }

    //    public string Description
    //    {
    //        get { return "Opens the Folder Containing the Item"; }
    //    }

    //    public string ParamDescription
    //    {
    //        get { return "Unused"; }
    //    }

    //    public string ParameterType
    //    {
    //        get { return "Command Line"; }
    //    }

    //    public bool Perform(IItem item, object specialParams)
    //    {
    //        try
    //        {
    //            Items.StartMenuItem SMItem = ((Items.StartMenuItem)(item));
    //            string actualPath = "";
    //            object Obj;

    //            Obj = Interaction.CreateObject("WScript.Shell");
    //            object Shortcut;
    //            Shortcut = Obj.CreateShortcut(SMItem.Path);
    //            actualPath = Shortcut.TargetPathShortcut.Save;
    //            return functionReturnValue;
    //        }
    //        catch
    //        {
    //            return false;
    //        }
    //    }

    //    #endregion
    //}
    
}
